﻿using System.Collections.Generic;

namespace Sex
{
    public partial class Sex : System.Web.UI.Page
    {
        public class MediaTemplate
        {
            public static int CompareTemplates(MediaTemplate x, MediaTemplate y)
            {
                return x.Name.CompareTo(y.Name);
            }
            public int Id;
            public bool UseWithImage;
            public bool UseWithAudio;
            public bool UseWithVideo;
            public string Name;
            public string Template;
            public MediaTemplate(int Id, bool UseWithImage, bool UseWithAudio, bool UseWithVideo, string Name, string Template)
            {
                this.Id = Id;
                this.UseWithImage = UseWithImage;
                this.UseWithAudio = UseWithAudio;
                this.UseWithVideo = UseWithVideo;
                this.Name = Name;
                this.Template = Template;
            }
            public string InstantiateTemplate(string Width, string Height, string Name)
            {
                return Template.Replace("#Width#", Width).Replace("#Height#", Height).Replace("#Name#", Name).Replace("&lt;script", "<" + "script").Replace("&lt;/script&gt;", "<" + "/script" + ">");
            }
        }
        public static class MediaTemplates
        {
            public static string InstantiateTemplate(int id, string Width, string Height, string Name)
            {
                return list[id].Template.Replace("#Width#", Width).Replace("#Height#", Height).Replace("#Name#", Name);
            }
            public static bool IsSorted = false;
            public static void Sort()
            {
                if (!IsSorted)
                {
                    list.Sort(MediaTemplate.CompareTemplates);
                    IsSorted = true;
                }
            }

            public static int IdToFind = -1;
            public static MediaTemplate Get(int id)
            {
                IdToFind = id;
                return list.Find(
                delegate(MediaTemplate mt)
                {
                    return (IdToFind == mt.Id);
                });

            }
            // the following construct does not work with framework 2.0 when running in single file mode
            public static List<MediaTemplate> list = new List<MediaTemplate>() 
            {
                new MediaTemplate
                (
                    0,
                    true,
                    false,
                    false,
                    "Image-Tag",
                    "<img \r\n"
                    + "  src='#Name#'\r\n"
                    + "  width='#Width#'\r\n"
                    + "  height='#Height#'\r\n"
                    + "/>\r\n"
                ),
                // http://webplayer.yahoo.com/docs/how-to-set-up/
                // http://webplayer.yahoo.com/docs/how-to-use/
                new MediaTemplate
                (
                    1,
                    false,
                    true,
                    true,
                    "Yahoo Player",
                    "<a href='#Name#'>Play Song</a><br/>"
                    + "&lt;script type='text/javascript' src='http://mediaplayer.yahoo.com/js'>\r\n"
                    + "&lt;/script&gt;\r\n"
                ),
                new MediaTemplate
                (
                    2,
                    false,
                    true,
                    true,
                    "Google Player",
                    "<embed \r\n"
                    + "  type='application/x-shockwave-flash' \r\n"
                    + "  wmode='transparent' \r\n"
                    + "  src='http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=#Name#' \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "></embed>\r\n"
                ),
                new MediaTemplate
                (
                    3,
                    false,
                    true,
                    false,
                    "Quicktime",
                    "<object \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' \r\n" 
                    + "  codebase='http://www.apple.com/qtactivex/qtplugin.cab'"
                    +"> \r\n"
                    + "  <param name='src' \r\n"
                    + "    value='#Name#' \r\n"
                    + "  />\r\n"
                    + "  <param \r\n"
                    + "    name='controller' \r\n"
                    + "    value='true' \r\n"
                    + "  />\r\n"
                    + "</object>\r\n"
                ),
                new MediaTemplate
                (
                    4,
                    false,
                    true,
                    false,
                    "Flash",
                    "<object \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' \r\n"
                    + "  codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'\r\n"
                    + ">\r\n" 
                    + "  <param \r\n"
                    + "    name='src' \r\n"
                    + "    value='#Name#'\r\n"
                    + "  >\r\n"
                    + "  <embed \r\n"
                    + "    src='#Name#' \r\n"
                    + "    height='#Height#' \r\n"
                    + "    width='#Width#' \r\n"
                    + "    type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'\r\n"
                    + "  ></embed>\r\n"
                    + "</object>\r\n"
                ),
                new MediaTemplate
                (
                    5,
                    false,
                    true,
                    false,
                    "Media Player",
                    "<object \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  type='video/x-ms-asf' url='#Name#' data='#Name#' \r\n"
                    + "  classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'> \r\n"
                    + "  <param name='url' value='#Name#'> \r\n"
                    + "  <param name='filename' value='#Name#'> \r\n"
                    + "  <param name='autostart' value='1'> \r\n"
                    + "  <param name='uiMode' value='full' /> \r\n"
                    + "  <param name='autosize' value='1'> \r\n"
                    + "  <param name='playcount' value='1'> \r\n" 
                    + "  <embed \r\n"
                    + "    type='application/x-mplayer2' \r\n"
                    + "    src='#Name#' \r\n"
                    + "    width='#Width#' \r\n"
                    + "    height='#Height#' \r\n"
                    + "    autostart='true' \r\n"
                    + "    showcontrols='true' \r\n"
                    + "    pluginspage='http://www.microsoft.com/Windows/MediaPlayer/'>\r\n"
                    + "  </embed>\r\n"
                    + "</object>\r\n"
                ),
                new MediaTemplate
                (
                    6,
                    false,
                    true,
                    false,
                    "Media Player-2",
                    "<OBJECT ID='MediaPlayer' \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  CLASSID='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95'\r\n"
                    + "  STANDBY='Loading Windows Media Player components...' \r\n"
                    + "  TYPE='application/x-oleobject'>\r\n"
                    + "  <PARAM NAME='FileName' \r\n"
                    + "    VALUE='#Name#'\r\n"
                    + "  >\r\n"
                    + "  <EMBED TYPE='application/x-mplayer2' \r\n"
                    + "    height='#Height#' \r\n"
                    + "    width='#Width#' \r\n"
                    + "    src='#Name#'\r\n"
                    + "    name='MediaPlayer'>\r\n"
                    + "</EMBED>\r\n"
                    + "</object>\r\n"
                ),  
                new MediaTemplate
                (
                    7,
                    false,
                    false,
                    true,
                    "Object-Tag",
                    "<object \r\n"
                    + "  data='#Name#' \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "/>\r\n"
                ),
                new MediaTemplate
                (
                    8,
                    false,
                    false,
                    true,
                    "Embed-Tag",
                    "<embed \r\n"
                    + "  autostart='true' \r\n"
                    + "  src='#Name#' \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "/>\r\n"
                ),
                new MediaTemplate
                (
                    9,
                    false,
                    false,
                    true,
                    "Video-Tag",
                    "<video \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  controls='controls'\r\n"
                    + ">\r\n"
                    + "  <source src='#Name#' type='video/mp4' />\r\n"
                    + "  Your browser does not support the video tag.\r\n"
                    + "</video>\r\n"
                ),
                new MediaTemplate
                (
                    10,
                    false,
                    false,
                    true,
                    "Using Video-, Embed- and Object-Tag",
                    "<video \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  controls='controls'>\r\n"
                    + "  <source \r\n"
                    + "    src='#Name#' \r\n"
                    + "    type='video/mp4' \r\n"
                    + "    />\r\n"
                    + "  <object \r\n"
                    + "    data='#Name#' \r\n"
                    + "    height='#Height#' \r\n"
                    + "    width='#Width#' \r\n"
                    + "  >\r\n"
                    + "    <embed \r\n"
                    + "      src='#Name#' \r\n"
                    + "      height='#Height#' \r\n"
                    + "      width='#Width#' \r\n"
                    + "    >\r\n"
                    + "      Your browser does not support video\r\n"
                    + "    </embed>\r\n"
                    + "  </object>\r\n" 
                    + "</video>\r\n"
                ),
                new MediaTemplate
                (
                    11,
                    true,
                    true,
                    true,
                    "iframe-Tag",
                    "<iframe \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  src='#Name#' \r\n"
                    + "  frameborder='0' \r\n"
                    + "  marginwidth='0' \r\n"
                    + "  marginheight='0' \r\n"
                    + "  scrolling='auto' \r\n"
                    + "> \r\n"
                    + "</iframe>\r\n"
                ),
                new MediaTemplate
                (
                    12,
                    true,
                    true,
                    true,
                    "Link",
                    "<a \r\n"
                    + "  href='#Name#' \r\n"
                    + "  target='_blank' \r\n"
                    + ">#Name# \r\n"
                    + "</a>\r\n"
                ),
                new MediaTemplate
                (
                    13,
                    false,
                    true,
                    true,
                    "Yahoo Player-2",
                    "<a href='#Name#'>Play Song</a><br/>"
                    + "&lt;script type='text/javascript' src='http://webplayer.yahooapis.com/player.js'>\r\n"
                    + "&lt;/script&gt;\r\n"
                ),
                new MediaTemplate
                (
                    14,
                    true,
                    true,
                    true,
                    "NewWin",
                    "<script  type='text/javascript'>\r\n"
                    + " window.open('#Name#','SexNew')\r\n"
                    + "</" + "script>\r\n"
                ),
                new MediaTemplate
                (
                    15,
                    true,
                    true,
                    true,
                    "ORF-TvThek",
                    "\r\n<object id='WmPlayerObject' type='application/x-ms-wmp' standby='Lade Windows Media Player Komponente...' style='width:27.4em;height:18.9em;'>"
                        + "\r\n<param name='URL' value='#Name#' />"
                        + "\r\n<param name='stretchToFit' value='true' />"
                        + "\r\n<param name='AutoSize' value='1' />"
                        + "\r\n<param name='captioningID' value='subtitles_captioning_id' />"
                        + "\r\n<param name='uimode' value='full' />         "
                        + "\r\n<param name='autoStart' value='false' />"
                        + "\r\n<embed type='application/x-mplayer2' "
                            + "pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/' "
                            + "src='#Name#' "
                            + "id='WmPlayerEmbed' "
                            + "name='WmPlayerObject' "
                            + "uiMode='full' "
                            + "ShowDisplay='0' "
                            + "captioningID='subtitles_captioning_id' "
                            + "ShowStatusBar='1' "
                            + "AutoStart='0' "
                            + "AutoSize='1' "
                            + "stretchToFit='true' "
                            + "scale='ASPECT' "
                            + "style='width:#Width#;height:#Height#;' "
                            + "airplay='allow' "
                        + "\r\n/>"
                        + "\r\n<p class='missing-plugin-hint'>Bitte installieren Sie das <a href='http://www.google.com/search?q=windows+media+player+browser+plugin+download'"
                            + "title='Google Suche nach WMP Plugin'>Windows Media Player Plugin</a>"
                        + "\r\n</p>"
                      + "\r\n</object>"
                )
            };
        }
    }
}